<?php use Backend\Controller\Plugin\AuthorizationPlugin; ?>

<?php echo $this->partial('sejour/sejourNavPartial', array (
    'sejourId' => $this->id
  ));
?>

<div ng-app="sejourModule">
	<div class="table-responsive" ng-controller="FicheSejourController">
		<div class="row">

			<input type="hidden" id="id" value="<?php echo $this->id;?>">
			<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{alert.msg}}</alert>

			<div class="panel panel-primary">
				<div class="panel-heading">Ajouter un nouveau contenu &#224; la fiche</div>
				<div class="panel-body">
					<form name="formFiche" class="formFiche" novalidate>
						
						<div class="row">
							<div class="col-lg-6">
									<div class="form-group">
										<label for="ficheTitre">Titre</label>
										<input id="ficheTitre" ng-model="ficheFrm.ficheTitre" type="text" placeholder="Notez le titre" class="form-control">
									</div>
							</div>
							<div class="col-lg-6">
								<div class="row">
									<div class="col-lg-6">
										<div class="row">
											<div class="col-lg-6">
												<div class="form-group">
													<label>&nbsp;</label>
													<button ng-click="post()" ng-disabled="formFiche.$invalid || !formFiche.$dirty" type="button" class="form-control btn btn-primary">{{ficheFrm.idFiche == null ? addButton : updateButton}}</button>
												</div>
											</div>
											<div class="col-lg-6">
												<div class="form-group">
													<label>&nbsp;</label>
													<button ng-click="cancel()" ng-disabled="!formFiche.$dirty" type="button" class="form-control btn btn-default">Annuler</button>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-lg-6">
								<div class="form-group">
									<label for="ficheContenu">Contenu</label>
									<textarea ck-editor id="ficheContenu" ng-model="ficheFrm.ficheContenu" name="editor1"></textarea>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>	
		</div>

		<div class="row">
			<div class="panel panel-default">
				<div class="panel-heading">Contenus de la fiche</div>
				<table class="table table-bordered table-hover table-striped tablesorter">
			    	<thead>
			        	<tr>
							<th class="col-sm-3">Titre </th>
							<th class="col-sm-7">Contenu </th>
							<th class="col-sm-2">&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<tr ng-repeat="fiche in fiches">
								<td>{{fiche.ficheTitre}}</td>
								<td><div ng-bind-html="fiche.ficheContenu"></div></td>
								<td>
									<div class="btn-group">
										<button type="button" class="btn btn-primary">Actions</button>
									  	<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
									    	<span class="caret"></span>
									    	<span class="sr-only">Toggle Dropdown</span>
									  	</button>
									  	<ul class="dropdown-menu" role="menu">
							    			<li><a href="#" ng-click="editerFiche(fiche)">Editer</a></li>
							    			<li><a href="#" ng-click="deleteFiche(fiche)">Supprimer</a></li>
									  	</ul>
									</div>
								</td>
							</tr>
					</tbody>
				</table>
			</div>

			
		</div>
	</div>
</div>	
